using System;

namespace octalforty.Syndication.Core.Rss
{
    /// <summary>
    /// Provides a base class for RSS entities.
    /// </summary>
    public abstract class RssEntityBase
    {
        #region Private Member Variables
        private String title = String.Empty;
        private String link = String.Empty;
        private String description = String.Empty;
        private DateTime? publishedOn = DateTime.Now;
        private RssCategoryCollection categories = new RssCategoryCollection();
        #endregion

        #region Public Properties
        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains the name of the entity.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// When <paramref name="value"/> is a <c>null</c> reference.
        /// </exception>
        public virtual String Title
        {
            get { return title; }
            set
            {
                if(value == null)
                    throw new ArgumentNullException("value");

                title = value;
            }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains tthe URL to the HTML 
        /// website corresponding to the entitiy.
        /// </summary>
        /// <exception cref="ArgumentNullException">
        /// When <paramref name="value"/> is a <c>null</c> reference.
        /// </exception>
        public virtual String Link
        {
            get { return link; }
            set
            {
                if(value == null)
                    throw new ArgumentNullException("value");

                link = value;
            }
        }

        /// <summary>
        /// Gets or sets a <see cref="String"/> which contains a phrase or sentence 
        /// describing the entity.
        /// </summary>
        public virtual String Description
        {
            get { return description; }
            set { description = value; }
        }

        /// <summary>
        /// Gets or sets a <see cref="DateTime"/> which contains the publication 
        /// date for the content.
        /// </summary>
        /// <remarks>
        /// For example, the New York Times publishes on a daily basis, the publication date flips once every 
        /// 24 hours. That's when the <see cref="PublishedOn"/> of the channel changes. All date-times in RSS 
        /// conform to the Date and Time Specification of RFC 822, with the exception that the year may be 
        /// expressed with two characters or four characters (four preferred).
        /// </remarks>
        public virtual DateTime? PublishedOn
        {
            get { return publishedOn; }
            set { publishedOn = value; }
        }

        /// <summary>
        /// Gets a reference to the <see cref="RssCategoryCollection"/> which contains
        /// <see cref="RssCategory"/> objects which specify categories this entity belongs to.
        /// </summary>
        public virtual RssCategoryCollection Categories
        {
            get { return categories; }
        }
        #endregion

        /// <summary>
        /// Initializes a new instance of <see cref="RssEntityBase"/> class.
        /// </summary>
        protected RssEntityBase()
        {
        }

        /// <summary>
        /// Initializes a new instance of <see cref="RssEntityBase"/> class
        /// with a given title, link and description.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="link"></param>
        /// <param name="description"></param>
        protected RssEntityBase(string title, string link, string description)
        {
            this.title = title;
            this.link = link;
            this.description = description;
        }
    }
}